<?php

/**
 * DatabaseSource form base class.
 *
 * @method DatabaseSource getObject() Returns the current form's model object
 *
 * @package    ecrm
 * @subpackage form
 * @author     Saul Santiago
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDatabaseSourceForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'name'          => new sfWidgetFormInputText(),
      'driver'        => new sfWidgetFormInputText(),
      'server'        => new sfWidgetFormInputText(),
      'username'      => new sfWidgetFormInputText(),
      'password'      => new sfWidgetFormInputText(),
      'table_source'  => new sfWidgetFormInputText(),
      'id_column'     => new sfWidgetFormInputText(),
      'last_id'       => new sfWidgetFormInputText(),
      'custom_sql'    => new sfWidgetFormInputText(),
      'campaign_name' => new sfWidgetFormInputText(),
      'invalid'       => new sfWidgetFormInputText(),
      'created_at'    => new sfWidgetFormDateTime(),
      'updated_at'    => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'name'          => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'driver'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'server'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'username'      => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'password'      => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'table_source'  => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'id_column'     => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'last_id'       => new sfValidatorInteger(array('required' => false)),
      'custom_sql'    => new sfValidatorPass(array('required' => false)),
      'campaign_name' => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'invalid'       => new sfValidatorInteger(array('required' => false)),
      'created_at'    => new sfValidatorDateTime(),
      'updated_at'    => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('database_source[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'DatabaseSource';
  }

}
